/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.manchini.stereocv.telas;

import br.com.manchini.stereocv.utils.CamResolucao;
import br.com.manchini.stereocv.utils.ImgUtils;
import br.com.manchini.stereocv.utils.MatcherUtils;
import br.com.manchini.stereocv.utils.RobustMatcher;
import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.FrameGrabber;
import com.googlecode.javacv.OpenCVFrameGrabber;
import static com.googlecode.javacv.cpp.opencv_core.*;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import com.googlecode.javacv.cpp.opencv_nonfree;
import de.congrace.exp4j.Calculable;
import de.congrace.exp4j.ExpressionBuilder;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;


import javax.swing.JOptionPane;

/**
 *
 * @author manchini
 */
public class DisparidadePixelOffset extends javax.swing.JDialog {

    private Thread thread;
    private static OpenCVFrameGrabber grabberEsq;
    private static CanvasFrame canvasFrameEsq;
    private static IplImage imgEsq;
    //
    private static OpenCVFrameGrabber grabberDir;
    private static CanvasFrame canvasFrameDir;
    private static IplImage imgDir;
    private static CanvasFrame canvasFrame;
    CvMat Q = new CvMat(cvLoad("Q.xml", null, null, null));
    CvMat M1 = new CvMat(cvLoad("M1.xml", null, null, null));
    CvMat M2 = new CvMat(cvLoad("M2.xml", null, null, null));
    CvMat D1 = new CvMat(cvLoad("D1.xml", null, null, null));
    CvMat D2 = new CvMat(cvLoad("D2.xml", null, null, null));
    CvMat R1 = new CvMat(cvLoad("R1.xml", null, null, null));
    CvMat R2 = new CvMat(cvLoad("R2.xml", null, null, null));
    CvMat mx1 = new CvMat(cvLoad("mx1.xml", null, null, null));
    CvMat my1 = new CvMat(cvLoad("my1.xml", null, null, null));
    CvMat mx2 = new CvMat(cvLoad("mx2.xml", null, null, null));
    CvMat my2 = new CvMat(cvLoad("my2.xml", null, null, null));
    private int segundo;
    private int fps;
    private boolean foto;

    /**
     * Creates new form ImagemSequencia
     */
    public DisparidadePixelOffset(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();

        jComboBox_resolucao.setModel(new DefaultComboBoxModel(CamResolucao.values()));
        jComboBox_resolucao.setSelectedIndex(1);
    }

    private void carregaFoto() {
        try {
            Integer aux = (Integer) jSpinner_Cont.getValue();

            imgEsq = cvLoadImage("img/" + aux + "esq.jpg");

            if (jCheckBox_Retificar.isSelected()) {

                cvRemap(imgEsq, imgEsq, mx1, my1, CV_INTER_LINEAR, CvScalar.ZERO);

            }
            if (canvasFrameEsq == null) {
                canvasFrameEsq = new CanvasFrame("Cam Esq");
                jPanel_camesq.add(canvasFrameEsq.getCanvas());
                canvasFrameEsq.getCanvas().addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        calculaModulo(e.getX(), e.getY());
                    }
                });


                canvasFrameEsq.setCanvasSize(imgEsq.width(), imgEsq.height());
            }
            canvasFrameEsq.showImage(imgEsq);

            imgDir = cvLoadImage("img/" + aux + "dir.jpg");
            if (jCheckBox_Retificar.isSelected()) {

                cvRemap(imgDir, imgDir, mx2, my2, CV_INTER_LINEAR, CvScalar.ZERO);
            }
            if (canvasFrameDir == null) {
                canvasFrameDir = new CanvasFrame("dir");
                jPanel_camdir.add(canvasFrameDir.getCanvas());
                canvasFrameDir.setCanvasSize(imgDir.width(), imgDir.height());
            }
            canvasFrameDir.showImage(imgDir);




        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, "Erro");
            ex.printStackTrace();
        }
    }

    private void captura() {
    }

    private void calculaModulo(int x, int y) {

        RobustMatcher rMatcher = new RobustMatcher(
                0.50,
                3.0,
                0.65F,
                new opencv_nonfree.SURF(10));

        RobustMatcher.Result matches = rMatcher.matchImages(imgEsq, imgDir,null,null);
        matches.getMatches();

        CvPoint2D32f[] points = MatcherUtils.toCvPoint2D32f(matches.getMatches(), matches.getKeyPoints1(), matches.getKeyPoints2());
        CvPoint2D32f point1 = points[0];
        CvPoint2D32f point2 = points[1];

        int indexPontoMaisProximo = MatcherUtils.getIndexPontoMaisProximo(x, y, point1);



        StringBuilder st = new StringBuilder();
        st.append("Esq: ").append(point1.position(indexPontoMaisProximo).x()).append(" x ").append(point1.position(indexPontoMaisProximo).y());
        st.append(" Dir: ").append(point2.position(indexPontoMaisProximo).x()).append(" x ").append(point2.position(indexPontoMaisProximo).y());
        
        float modulo = (point1.position(indexPontoMaisProximo).x() - point2.position(indexPontoMaisProximo).x());
        st.append("Modulo: ").append(modulo);

        jLabel_saida.setText(st.toString());

        Calculable calc = null;
        try {
            calc = new ExpressionBuilder(jTextFieldEntrada.getText())
                    .withVariable("x", modulo).build();
            Double resultado = calc.calculate();

            jLabel_Formula.setText(resultado.toString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        jLabel_saida.setText(st.toString());
        System.out.println(st.toString());
        
        // Calculo no modelo canonico
        
        try{
            float d = (point1.position(indexPontoMaisProximo).x() - point2.position(indexPontoMaisProximo).x());

            float Z = ((Double)Q.get(2, 3)).floatValue();
            float W = d * ((Double)Q.get(3, 2)).floatValue() + ((Double)Q.get(3, 3)).floatValue();

            Z = Z / W;
            

            System.out.println("Z = "+Z);
            jLabel_SaidaCanonico.setText(new Float(Z).toString());
        }catch(Exception ex){
            ex.printStackTrace();
        }
        


        int xp = new Long(Math.round(point1.position(indexPontoMaisProximo).x())).intValue();
        int yp = new Long(Math.round(point1.position(indexPontoMaisProximo).y())).intValue();

        CvMat imgEsqT = CvMat.create(imgEsq.asCvMat().rows(), imgEsq.asCvMat().cols(), imgEsq.asCvMat().type());
        cvCopy(imgEsq, imgEsqT);
        cvCircle(imgEsqT, new CvPoint(xp, yp), 3, CvScalar.RED, 1, CV_AA, 0);
        canvasFrameEsq.showImage(imgEsqT.asIplImage());

        xp = new Long(Math.round(point2.position(indexPontoMaisProximo).x())).intValue();
        yp = new Long(Math.round(point2.position(indexPontoMaisProximo).y())).intValue();

        CvMat imgDirT = CvMat.create(imgDir.asCvMat().rows(), imgDir.asCvMat().cols(), imgDir.asCvMat().type());
        cvCopy(imgDir, imgDirT);
        cvCircle(imgDirT, new CvPoint(xp, yp), 3, CvScalar.RED, 1, CV_AA, 0);
        canvasFrameDir.showImage(imgDirT.asIplImage());
    }

    private void liveAction() {
        Integer camEsq = (Integer) jSpinner_esq.getValue();
        Integer camDir = (Integer) jSpinner_dir.getValue();


        CamResolucao camResolucao = (CamResolucao) jComboBox_resolucao.getSelectedItem();
        if (camEsq != -1) {
            try {
                grabberEsq = new OpenCVFrameGrabber(camEsq);
                grabberEsq.setImageWidth(camResolucao.getW());
                grabberEsq.setImageHeight(camResolucao.getH());
                grabberEsq.start();

                imgEsq = grabberEsq.grab();
                canvasFrameEsq = new CanvasFrame("Cam Esq");
                jPanel_camesq.add(canvasFrameEsq.getCanvas());
                canvasFrameEsq.setCanvasSize(imgEsq.width(), imgEsq.height());

                grabberEsq.setFrameRate(grabberEsq.getFrameRate());

                canvasFrameEsq.getCanvas().addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        calculaModulo(e.getX(), e.getY());

                    }
                });






//                canvasFrameEsq.showImage(imgEsq);
            } ////
            catch (FrameGrabber.Exception ex) {
                Logger.getLogger(AjusteDisparidade.class.getName()).log(Level.SEVERE, null, ex);
            }


        }


        ////


        ///
        if (camDir != -1) {
            try {
                grabberDir = new OpenCVFrameGrabber(camDir);
                grabberDir.setImageWidth(camResolucao.getW());
                grabberDir.setImageHeight(camResolucao.getH());
                grabberDir.start();

                imgDir = grabberDir.grab();
                canvasFrameDir = new CanvasFrame("Cam Dir");
                jPanel_camdir.add(canvasFrameDir.getCanvas());
                canvasFrameDir.setCanvasSize(imgDir.width(), imgDir.height());
                canvasFrameDir.getCanvas().addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                    }
                });

                grabberDir.setFrameRate(grabberDir.getFrameRate());

            } catch (FrameGrabber.Exception ex) {
                Logger.getLogger(AjusteDisparidade.class.getName()).log(Level.SEVERE, null, ex);
            }

        }


        new Thread(new Runnable() {
            @Override
            public void run() {

                while (true) {
                    try {

                        if (foto) {
                            int i = (Integer) jSpinner_Cont.getValue();
                            cvSaveImage("img/" + i + "esq.jpg", imgEsq);
                            cvSaveImage("img/" + i + "dir.jpg", imgDir);
                            foto = false;
                            jSpinner_Cont.getModel().setValue(jSpinner_Cont.getModel().getNextValue());
                        }

                        if (jCheckBox_NaoAtualiza.isSelected()) {
                            try {
                                Thread.sleep(200);
                            } catch (InterruptedException ex) {
                                Logger.getLogger(DisparidadePixelOffset.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            continue;
                        }

                        IplImage imgEsqOriginal = grabberEsq.grab();

                        if (jCheckBox_Rotaciona.isSelected()) {
                            ImgUtils.rotacionaImagem(imgEsqOriginal, imgEsq);
                        } else {
                            imgEsq = imgEsqOriginal;
                        }



                        IplImage imgDirOriginal = grabberDir.grab();

                        if (jCheckBox_Rotaciona.isSelected()) {
                            ImgUtils.rotacionaImagem(imgDirOriginal, imgDir);
                        } else {
                            imgDir = imgDirOriginal;
                        }
                        if (jCheckBox_Retificar.isSelected()) {
                            cvRemap(imgDir, imgDir, mx2, my2, CV_INTER_LINEAR, CvScalar.ZERO);
                            cvRemap(imgEsq, imgEsq, mx1, my1, CV_INTER_LINEAR, CvScalar.ZERO);
                        }

                        canvasFrameEsq.showImage(imgEsq);
                        canvasFrameDir.showImage(imgDir);




                    } catch (FrameGrabber.Exception ex) {
                        Logger.getLogger(AjusteDisparidade.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }

            }
        }).start();

        canvasFrame = new CanvasFrame("Disparidade");
    }

    private void foto() {

        foto = true;






    }

    private void todosPontos() {

        RobustMatcher rMatcher = new RobustMatcher(
                0.50,
                3.0,
                0.65F,
                new opencv_nonfree.SURF(10));

        RobustMatcher.Result matches = rMatcher.matchImages(imgEsq, imgDir,null,null);
        matches.getMatches();

        CvPoint2D32f[] points = MatcherUtils.toCvPoint2D32f(matches.getMatches(), matches.getKeyPoints1(), matches.getKeyPoints2());
        CvPoint2D32f point1 = points[0];
        CvPoint2D32f point2 = points[1];



        CvMat imgEsqT = CvMat.create(imgEsq.asCvMat().rows(), imgEsq.asCvMat().cols(), imgEsq.asCvMat().type());
        cvCopy(imgEsq, imgEsqT);
        for (int i = 0; i < point1.capacity(); i++) {
            int xp = new Long(Math.round(point1.position(i).x())).intValue();
            int yp = new Long(Math.round(point1.position(i).y())).intValue();

            cvCircle(imgEsqT, new CvPoint(xp, yp), 3, CvScalar.RED, 1, CV_AA, 0);
        }
        canvasFrameEsq.showImage(imgEsqT.asIplImage());


        CvMat imgDirT = CvMat.create(imgDir.asCvMat().rows(), imgDir.asCvMat().cols(), imgDir.asCvMat().type());
        cvCopy(imgDir, imgDirT);
        for (int i = 0; i < point2.capacity(); i++) {
            int xp = new Long(Math.round(point2.position(i).x())).intValue();
            int yp = new Long(Math.round(point2.position(i).y())).intValue();
            cvCircle(imgDirT, new CvPoint(xp, yp), 3, CvScalar.RED, 1, CV_AA, 0);

        }
        canvasFrameDir.showImage(imgDirT.asIplImage());
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel7 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jSpinner_esq = new javax.swing.JSpinner();
        jLabel2 = new javax.swing.JLabel();
        jSpinner_dir = new javax.swing.JSpinner();
        jCheckBox_Rotaciona = new javax.swing.JCheckBox();
        jComboBox_resolucao = new javax.swing.JComboBox();
        jCheckBox_Retificar = new javax.swing.JCheckBox();
        jPanel2 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jSpinner_Cont = new javax.swing.JSpinner();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jCheckBox_NaoAtualiza = new javax.swing.JCheckBox();
        jButton5 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel_saida = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel_saida3 = new javax.swing.JLabel();
        jTextFieldEntrada = new javax.swing.JTextField();
        jLabel_Formula = new javax.swing.JLabel();
        jPanel9 = new javax.swing.JPanel();
        jLabel_saida4 = new javax.swing.JLabel();
        jLabel_SaidaCanonico = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jPanel_camesq = new javax.swing.JPanel();
        jPanel_camdir = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jLabel_FPS = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                formMouseClicked(evt);
            }
        });

        jPanel7.setLayout(new javax.swing.BoxLayout(jPanel7, javax.swing.BoxLayout.Y_AXIS));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Cameras"));

        jLabel1.setText("Esquerda");
        jPanel1.add(jLabel1);

        jSpinner_esq.setModel(new javax.swing.SpinnerNumberModel(1, -1, 5, 1));
        jPanel1.add(jSpinner_esq);

        jLabel2.setText("Direita");
        jPanel1.add(jLabel2);

        jSpinner_dir.setModel(new javax.swing.SpinnerNumberModel(2, -1, 5, 1));
        jPanel1.add(jSpinner_dir);

        jCheckBox_Rotaciona.setText("Rotaciona Imagem");
        jCheckBox_Rotaciona.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox_RotacionaActionPerformed(evt);
            }
        });
        jPanel1.add(jCheckBox_Rotaciona);

        jPanel1.add(jComboBox_resolucao);

        jCheckBox_Retificar.setText("Retificar");
        jCheckBox_Retificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox_RetificarActionPerformed(evt);
            }
        });
        jPanel1.add(jCheckBox_Retificar);

        jPanel7.add(jPanel1);

        jButton4.setText("Carrega Fotos");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton4);

        jSpinner_Cont.setModel(new javax.swing.SpinnerNumberModel(1, 0, 99999, 10));
        jPanel2.add(jSpinner_Cont);

        jButton2.setText("Live Action");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2);

        jButton3.setText("Gravar Img");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton3);

        jCheckBox_NaoAtualiza.setText("Nao Atualiza Tela");
        jCheckBox_NaoAtualiza.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox_NaoAtualizaActionPerformed(evt);
            }
        });
        jPanel2.add(jCheckBox_NaoAtualiza);

        jButton5.setText("Todos Pontos ");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton5);

        jPanel7.add(jPanel2);

        jPanel3.add(jLabel_saida);

        jPanel7.add(jPanel3);

        jPanel8.setLayout(new java.awt.BorderLayout());
        jPanel7.add(jPanel8);

        jTabbedPane1.addTab("Inicializar Imagens", jPanel7);

        jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.Y_AXIS));

        jLabel_saida3.setText("Em Função de X");
        jPanel5.add(jLabel_saida3);

        jTextFieldEntrada.setText("x");
        jTextFieldEntrada.setPreferredSize(new java.awt.Dimension(450, 27));
        jPanel5.add(jTextFieldEntrada);
        jPanel5.add(jLabel_Formula);

        jPanel4.add(jPanel5);

        jLabel_saida4.setText("Canonico:");
        jPanel9.add(jLabel_saida4);
        jPanel9.add(jLabel_SaidaCanonico);

        jPanel4.add(jPanel9);

        jPanel6.setLayout(new java.awt.BorderLayout());
        jPanel4.add(jPanel6);

        jTabbedPane1.addTab("Calculadora", jPanel4);

        getContentPane().add(jTabbedPane1, java.awt.BorderLayout.NORTH);

        jPanel_camesq.setPreferredSize(new java.awt.Dimension(600, 300));
        jPanel_camesq.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel_camesqMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel_camesqLayout = new javax.swing.GroupLayout(jPanel_camesq);
        jPanel_camesq.setLayout(jPanel_camesqLayout);
        jPanel_camesqLayout.setHorizontalGroup(
            jPanel_camesqLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 600, Short.MAX_VALUE)
        );
        jPanel_camesqLayout.setVerticalGroup(
            jPanel_camesqLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 472, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel_camesq, java.awt.BorderLayout.WEST);

        jPanel_camdir.setPreferredSize(new java.awt.Dimension(600, 300));
        jPanel_camdir.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel_camdirMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel_camdirLayout = new javax.swing.GroupLayout(jPanel_camdir);
        jPanel_camdir.setLayout(jPanel_camdirLayout);
        jPanel_camdirLayout.setHorizontalGroup(
            jPanel_camdirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 600, Short.MAX_VALUE)
        );
        jPanel_camdirLayout.setVerticalGroup(
            jPanel_camdirLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 472, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel_camdir, java.awt.BorderLayout.EAST);

        jPanel10.setPreferredSize(new java.awt.Dimension(1287, 20));
        jPanel10.add(jLabel_FPS);

        getContentPane().add(jPanel10, java.awt.BorderLayout.PAGE_END);

        setSize(new java.awt.Dimension(1297, 669));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jCheckBox_RotacionaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_RotacionaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox_RotacionaActionPerformed

    private void jPanel_camesqMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel_camesqMouseClicked
    }//GEN-LAST:event_jPanel_camesqMouseClicked

    private void formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_formMouseClicked

    private void jPanel_camdirMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel_camdirMouseClicked
    }//GEN-LAST:event_jPanel_camdirMouseClicked

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        carregaFoto();
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        liveAction();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        foto();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jCheckBox_NaoAtualizaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_NaoAtualizaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox_NaoAtualizaActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        todosPontos();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jCheckBox_RetificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox_RetificarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCheckBox_RetificarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(DisparidadePixelOffset.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DisparidadePixelOffset.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DisparidadePixelOffset.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DisparidadePixelOffset.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                DisparidadePixelOffset dialog = new DisparidadePixelOffset(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JCheckBox jCheckBox_NaoAtualiza;
    private javax.swing.JCheckBox jCheckBox_Retificar;
    private javax.swing.JCheckBox jCheckBox_Rotaciona;
    private javax.swing.JComboBox jComboBox_resolucao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel_FPS;
    private javax.swing.JLabel jLabel_Formula;
    private javax.swing.JLabel jLabel_SaidaCanonico;
    private javax.swing.JLabel jLabel_saida;
    private javax.swing.JLabel jLabel_saida3;
    private javax.swing.JLabel jLabel_saida4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JPanel jPanel_camdir;
    private javax.swing.JPanel jPanel_camesq;
    private javax.swing.JSpinner jSpinner_Cont;
    private javax.swing.JSpinner jSpinner_dir;
    private javax.swing.JSpinner jSpinner_esq;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextFieldEntrada;
    // End of variables declaration//GEN-END:variables
}